//上移
function sortUp(obj,url){
	//判断是否可以上译
	var tr = obj.parent().parent();
	var this_sort = tr.attr("sort_id");
	var trHtml = "<tr sort_id='"+this_sort+"'>"+tr.html()+"</tr>";
	var prev = tr.prev();
	var prev_sort = prev.attr("sort_id");
	
	if(prev_sort!=undefined){
		prev.before(trHtml);
		tr.remove();
		//sortReset(url);
	}
}

//下移
function sortDown(obj,url){
	var tr = obj.parent().parent();
	var this_sort = tr.attr
	var trHtml = "<tr>"+tr.html()+"</tr>";
	var next = tr.next();
	if(next.text()!=''){
		next.after(trHtml);
		tr.remove();
		//sortReset(url);
	}else{
		tr.remove();
	}
}

//序号重新排列
function sortReset(url){
	var total = $(".sort").length;
	$(".sort").each(function(index){
		var sort = total-index;
		var id = $(this).attr("sort_id");
		$(this).val(sort);
		$.post(
			url,
			{id:id,sort:sort}
		)
	})
}